package com.hcs.chenyu.moreaboutstudent;

import android.os.Bundle;
import android.widget.ListView;
import android.widget.SimpleAdapter;

import androidx.appcompat.app.AppCompatActivity;

import com.hcs.chenyu.R;

import java.util.List;
import java.util.Map;

public class findallstudentinformation extends AppCompatActivity {
    ListView listView = null;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_findallstudentinformation);
        setTitle("查看记录");
        initview();
    }

    private void initview() {
        //建库访问对象
        Studentdao da = new Studentdao(getApplicationContext());
        //打开数据库
        da.open();
        //调用数据库访问方法
        List<Map<String,Object>> myOrderData=da.getAllstudents();

        //获取组件
        listView=(ListView)findViewById(R.id.lst_order);
        //定义数据源
        String[] from={"mstudentid","mstudentname","mstudentsex","mstudentmajoy","mstudentclass","mstudenttel","mstudentdormNo"};
        //定义布局控件ID
        int[] to={R.id.tv_lst_mstudentno,R.id.tv_lst_mstudentnames,R.id.tv_lst_mstudentsex,R.id.tv_lst_mstudentmajoy,R.id.tv_lst_mstudentclass,R.id.tv_lst_mstudenttel,R.id.tv_lst_mstudentdormNo};
        SimpleAdapter listItemAdapter=new SimpleAdapter(findallstudentinformation.this,myOrderData,R.layout.studentitem_list,from,to);
        //添加并显示
        listView.setAdapter(listItemAdapter);
        //关闭数据库
        da.close();
    }
}